<?php

include_once ('variables.php');
include_once (ROOT_DIR.'sessions.php');
include_once (ROOT_DIR.'init.php');

$save_type="MySQL";

$dbh = get_master_connect();

if (!$dbh) {
	echo "We are sorry but we cannot process your request at the moment<BR>";
	exit_now();
}

if (getenv(REQUEST_METHOD) == "POST") {
	$user = validate($_POST['username']);
	$email = validate($_POST['email']);

	$password = getResellerPasswordRP2($user, $email);
	
	if(!$password) {
		header("Location: $baseURL/lostpassword.html?ss=no match");
		exit_now();
	}
	else {
		system ("/usr/local/admin/mail.pl  '$user' '$password' '' '' '$email' '' '$baseDomain' '/www/resellers_advanced/admin/mails/lostpassword.txt' 'lostpassword' '$baseDomain'", $err);
		
		if($err <> 0 && $err <> 22) {
			header("Location: $baseURL/lostpassword.html?ss=error");
			exit_now();
			return 0;
		}
		
		header("Location: $baseURL/lostpassword.html?ss=found");
		exit_now();
	}
}

?>